Skip to content

feat: validate pycross package override labels - #298

Open
groodt wants to merge 1 commit into
jvolkman:mainfrom
groodt:groodt-validate-pycross-override-labels
Open

feat: validate pycross package override labels#298
groodt wants to merge 1 commit into
jvolkman:mainfrom
groodt:groodt-validate-pycross-override-labels

Conversation

@groodt

@groodt groodt commented Jul 24, 2026

Copy link
Copy Markdown

Context

At $dayjob we carry a rules_pycross patch that ensures we don't have stale lock_import in rules_pycross.MODULE.bazel. In this PR we are seeking to upstream this patch if it is useful or interesting to the maintainers.

It does this by generating a test that approximately looks like this:

_package_override_label_validation_test(
    name = "validate_package_override_labels",
    targets = [
        # A list of valid targets goes here
        ...
    ],
    visibility = ["//visibility:public"],
)

This enables the optional addition of a build_test to ensure that there are no stale `lock_imports.

load("@bazel_skylib//rules:build_test.bzl", "build_test")

build_test(
    name = "validate_pycross_package_overrides",
    tags = [
        "block-network",
        "unit",
    ],
    targets = ["@pycross_pypi//_lock:validate_package_override_labels"],
)

@groodt
groodt force-pushed the groodt-validate-pycross-override-labels branch from dcee8a3 to f0bba0c Compare July 24, 2026 03:01
@jvolkman

Copy link
Copy Markdown
Owner

Hey Greg, nice to hear from you. Just to make sure we're on the same page, lock_import doesn't exist anymore in v2 (see the migration note here). Are you all using v2, or v1 still?

@groodt

groodt commented Jul 24, 2026

Copy link
Copy Markdown
Author

We're on v1 and this was one patch we can ditch before upgrade to v2.

I probably should have looked at the v2 code first! 🤣

What's the nearest equivalent? Or is there no such thing in v2? Is the intent clear of what we're looking for?

@jvolkman

Copy link
Copy Markdown
Owner

There's still lock importing in v2, but it looks more like:

uv = use_extension("@rules_pycross//pycross/extensions:uv.bzl", "uv")
uv.workspace(
    name = "pypi",
    lock_file = "//:uv.lock",
)
uv.repo(
    workspace = "pypi",
)
uv.package(
    name = "numpy",
    always_build = True,
    workspace = "pypi",  # was: repo = "pypi"
)

(sub uv for pdm, poetry, etc.)

And there's still a //_lock, but it's in a mostly hidden "workspace" repository now. That workspace repository contains all of the packages in the lock, and then the actual pypi repository is some subset of those (only pinned packages, only packages from one workspace member project, etc.).

I think that's the largest conflict with this patch; it seems like it would work, but would require users to use that hidden workspace repo to access it, fighting with bazel mod tidy, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants